<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="../lib/react.development.js"></script>
    <script src="../lib/react-dom.development.js"></script>
    <script src="../lib/babel.js"></script>
</head>
<body>
<div id="example"></div>
<script type="text/jsx">

    class Ref extends React.Component{
        state = {
            textInput:React.createRef(),
        };
        handleRef = ()=> {
            this.refs.inputs.focus();
        };
        handleRef2 = ()=> {
            this.state.textInput.current.focus();
        };
        render() {
            return (
                <div>
                    <div>
                        <input type="text" ref="inputs" />
                        <button type="button" onClick={this.handleRef}>Click1</button>
                    </div>
                    <div>
                        <input type="text" ref={this.state.textInput}/>
                        <button type="button" onClick={this.handleRef2}>Click2</button>
                    </div>
                </div>
            )
        }
    }

    ReactDOM.render(
        <Ref />,
        document.getElementById('example')
    )

</script>
</body>
</html>